import { http } from '@/utils/http/axios';

export interface BasicResponseModel<T = any> {
  code: number;
  msg: string;
  data: T;
}

export interface BasicPageParams {
  pageNumber: number;
  pageSize: number;
  total: number;
}
export interface UserInfo {
  id?: number;
  name: string;
  sex: number;
  orgCode: number | string;
  idCard: string;
  roleId: number | string;
  phone: string;
  status: number;
  username: string;
  password: string;
}
export interface CertificateInfo {
  type: string;
  issueTime: string | undefined;
  expirationTime: string | undefined;
  name: string;
  certificateNumber: string;
  file: string;
  userId: number;
}


/**
 * @description: 用户修改密码
 */
export function changePassword(params, uid) {
  return http.request(
    {
      url: `/user/u${uid}/changepw`,
      method: 'POST',
      params,
    },
    {
      isTransformResponse: false,
    }
  );
}

/**
 * @description: 用户登出
 */
export function logout(params) {
  return http.request({
    url: '/login/logout',
    method: 'POST',
    params,
  });
}

/**
 * @description: 获取用户列表
 */
export function getUserList(params) {
  return http.request({
    url: '/sys/user',
    method: 'get',
    params,
  });
}
/**
 * @description: 获取用户列表
 */
export function getAllUser(params) {
  return http.request({
    url: '/sys/user/allUser',
    method: 'get',
    params,
  });
}
/**
 * @description: 获取用户信息
 */
export function getUserInfo(params) {
  return http.request({
    url: '/sys/user/info',
    method: 'get',
    params,
  });
}
/**
 * @description: 删除用户
 */
export function deleteUser(params) {
  return http.request({
    url: '/sys/user',
    method: 'DELETE',
    params,
  });
}
/**
 * @description: 用户新增
 */
export function createUser(data) {
  return http.request({
    url: '/sys/user',
    method: 'POST',
    data,
  });
}
/**
 * @description: 用户修改
 */
export function updateUser(data) {
  return http.request({
    url: '/sys/user',
    method: 'PUT',
    data,
  });
}
/**
 * @description: 获取证书列表
 */
export function getCertificateList(params) {
  return http.request({
    url: '/sys/cer',
    method: 'get',
    params,
  });
}
/**
 * @description: 获取证书信息
 */
export function getCertificateInfo(params) {
  return http.request({
    url: '/sys/cer/info',
    method: 'get',
    params,
  });
}
/**
 * @description: 删除证书
 */
export function deleteCertificate(params) {
  return http.request({
    url: '/sys/cer',
    method: 'DELETE',
    params,
  });
}
/**
 * @description: 证书新增
 */
export function createCertificate(data) {
  return http.request({
    url: '/sys/cer',
    method: 'POST',
    data,
  });
}
/**
 * @description: 证书修改
 */
export function updateCertificate(data) {
  return http.request({
    url: '/sys/cer',
    method: 'PUT',
    data,
  });
}
